<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('content')) {
            Schema::create('content', function (Blueprint $table) {
                $table->increments('id')->comment('主键ID');
                $table->integer('category_id')->default(0)->comment('分类ID');
                $table->string('logo', 128)->default('')->comment('logo');
                $table->string('title', 64)->default('')->comment('标题');
                $table->string('keywords', 128)->default('')->comment('关键字');
                $table->string('description', 256)->default('')->comment('描述');
                $table->tinyInteger('jump')->default(1)->comment('跳转方式（1：当前窗口，2：新窗口）');
                $table->string('jump_link', 256)->default('')->comment('跳转地址');
                $table->tinyInteger('sort')->default(0)->comment('排序');
                $table->tinyInteger('status')->default(2)->comment('状态（1：开启，2：禁用）');
                $table->datetime('created_at')->nullable()->useCurrent()->comment('创建时间');
                $table->datetime('updated_at')->nullable()->useCurrent()->useCurrentOnUpdate()->comment('更新时间');
                $table->datetime('deleted_at')->nullable()->comment('删除时间');
            });
            DB::statement(sprintf("ALTER TABLE `%s%s` comment '%s'", config('database.connections.mysql.prefix'), 'content', '导航内容表'));
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('content');
    }
};
